package com.lifeng.config;

import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
import com.mangofactory.swagger.models.dto.ApiInfo;
import com.mangofactory.swagger.plugin.EnableSwagger;
import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * Created by lifeng
 * 2017/12/11 17:33
 */
@EnableSwagger
@Component
public class MySwaggerConfig {
    @Autowired
    private SpringSwaggerConfig springSwaggerConfig;

    @Bean(name="springSwaggerConfig")
    public SpringSwaggerConfig getSpringSwaggerConfig(){
        return new SpringSwaggerConfig();
    }

    @Bean
    public SwaggerSpringMvcPlugin customImplementation(){
        return new SwaggerSpringMvcPlugin(this.springSwaggerConfig).apiInfo(apiInfo())
                .includePatterns(".*?");
    }

    private ApiInfo apiInfo(){
        ApiInfo apiInfo = new ApiInfo(
                "springmvc搭建swagger(标题)",
                "spring-API swagger测试(描述)",
                "(服务的url)",
                "729088240@qq.com",
                "license",
                "license URL");
        return apiInfo;
    }
}
